#ifndef SERIALWORKER_H
#define SERIALWORKER_H

#include <QObject>
#include <QSerialPort>
#include <QDataStream>
#include <QVector>
#include "messageparser.h"

class SerialWorker : public QObject {
    Q_OBJECT

  public:
    explicit SerialWorker(QObject *parent = nullptr);
    ~SerialWorker();

    bool openSerialPort(const QString &portName, qint32 baudRate);
    void closeSerialPort();
    void write(const char *);

  signals:
    void newData(QStringList data);

  private slots:
    void readData();
    void onNewData(QStringList data);

  private:
    QSerialPort *mSerialPort;
    // QDataStream mIn;
    // QQueue<QByteArray> dataQueue;
    // QMutex queueMutex;
    MessageParser mMsgParser;
};

#endif // SERIALWORKER_H
